﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace Sunny.Lib.DllHelper
{
    public class SunnyDll
    {
        /*
         * EntryPoint: 指定要调用的 DLL 入口点。默认入口点名称是托管方法的名称 。 
            CharSet: 控制名称重整和封送 String 参数的方式 (默认是UNICODE) 
            CallingConvention指示入口点的函数调用约定(默认WINAPI)(上次报告讲过的） 
            SetLastError 指示被调用方在从属性化方法返回之前是否调用 SetLastError Win32 API 函数 (C#中默认false ) 
            int 类型 
        */
        [DllImport(@"C:\Users\lenovo\Desktop\Sunny\dll\SunnyDll.dll", EntryPoint = "GetSecurityString")]
        public static extern IntPtr GetSecurityString(SecurityStringType securityStringType);
    }

    public class SunnyDllHelper
    {
        public static string GetSecurityString(SecurityStringType securityStringType)
        {
            string securityStr = string.Empty;
            IntPtr intP = SunnyDll.GetSecurityString(securityStringType);
            securityStr = Marshal.PtrToStringAnsi(intP);
            return securityStr;
        }
    }

    public enum SecurityStringType
    {
        EncryptKey8 = 1,
        EncryptKey16 = 2,
        EncryptKey24 = 3,
        EncryptKey32 = 4,
        EncryptIv8 = 5,
        EncryptIv16 = 6,
    }
}
